<script setup lang="ts">
import zhCN from "ant-design-vue/es/locale/zh_CN";
import dayjs from "dayjs";
import "dayjs/locale/zh-cn";
import { theme } from "ant-design-vue";
import { storageLocal, useDark } from "@pureadmin/utils";
defineOptions({
	name: "App",
});

dayjs.locale("zh-cn");
const locale = ref(zhCN);
const { isDark, toggleDark } = useDark();

onMounted(function () {
	const theme = storageLocal().getItem("es-client-tool-theme");
	if (theme === "dark") {
		if (!isDark.value) {
			toggleDark();
		}
	} else {
		if (isDark.value) {
			toggleDark();
		}
	}
});
</script>

<template>
	<a-config-provider
		:locale="locale"
		:theme="{
			algorithm: isDark ? theme.darkAlgorithm : theme.defaultAlgorithm,
		}"
	>
		<router-view />
	</a-config-provider>
</template>
